package com.cloud.api.myenum;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

public enum ModelEnum implements IEnum<Integer> {
    TRAILER(1, "拖挂车"),
    OFF_ROAD_CAR(2, "越野车");

    @EnumValue
    private Integer value;

    @Getter
    @JsonValue
    private String desc;

    ModelEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    @Override
    public String toString() {
        return String.valueOf(this.getValue());
    }


    public static ModelEnum getEnum(String desc) {
        for (ModelEnum modelEnum : ModelEnum.values()){
            if (modelEnum.getDesc().equals(desc)){
                return modelEnum;
            }
        }
        return null;
    }

}
